package com.wangsong.common.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {
    private String result;
    private T data;

    public static Result success() {
        return new Result(CodeEnum.SUCCESS.getCode(), null);
    }

    public static <T>Result success(T data) {
        return new Result(CodeEnum.SUCCESS.getCode(), data);
    }

    public static <T>Result success(String code, T data) {
        return new Result(code, data);
    }

    public static Result error() {
        return new Result(CodeEnum.ERROR.getCode(), null);
    }

    public static <T>Result error(String code, T data) {
        return new Result(code, data);
    }

    public static <T>Result error(T data) {
        return new Result(CodeEnum.ERROR.getCode(), data);
    }


}
